home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UUPC11QS.ARJ / PUSHPOP.C < prev    next >
C/C++ Source or Header  |  1991-11-21  |  2KB  |  74 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    p u s h p o p . c                                               */
  3. /*                                                                    */
  4. /*    Directory functions for UUPC/extended                           */
  5. /*                                                                    */
  6. /*    Copyright (c) 1989, 1991 Andrew H. Derbyhshire                  */
  7. /*--------------------------------------------------------------------*/
  8.  
  9. /*--------------------------------------------------------------------*/
  10. /*                        System include files                        */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <direct.h>
  16. #include <sys/types.h>
  17.  
  18. /*--------------------------------------------------------------------*/
  19. /*                    UUPC/extended include files                     */
  20. /*--------------------------------------------------------------------*/
  21.  
  22. #include "lib.h"
  23. #include "pushpop.h"
  24.  
  25. #define MAXDEPTH 10
  26.  
  27. /*--------------------------------------------------------------------*/
  28. /*                          Global variables                          */
  29. /*--------------------------------------------------------------------*/
  30.  
  31. static char *dirstack[MAXDEPTH];
  32. static depth = 0;
  33.  
  34. currentfile();
  35.  
  36. /*--------------------------------------------------------------------*/
  37. /*            Change to a directory and push on our stack             */
  38. /*--------------------------------------------------------------------*/
  39.  
  40. void PushDir( char *directory )
  41. {
  42.    if ( depth >= MAXDEPTH )
  43.       panic();
  44.  
  45. #ifdef __TURBOC__
  46.    dirstack[depth] = getcwd( NULL , FILENAME_MAX );
  47. #else
  48.    dirstack[depth] = _getdcwd( 0, NULL , FILENAME_MAX );
  49. #endif
  50.    if (dirstack[depth] == NULL )
  51.    {
  52.       printerr("PushDir");
  53.       panic();
  54.    }
  55.    CHDIR( directory );
  56.    depth++;
  57.    return;
  58. } /* PushDir */
  59.  
  60. /*--------------------------------------------------------------------*/
  61. /*               Return to a directory saved by PushDir               */
  62. /*--------------------------------------------------------------------*/
  63.  
  64. void PopDir( void )
  65. {
  66.    if ( depth == 0 )
  67.       panic();
  68.  
  69.    CHDIR( dirstack[--depth] );
  70.    free( dirstack[depth] );
  71.    return;
  72.  
  73. } /* PopDir */
  74.